<?php
$width=Yii::app()->params['dialog']['findCustomerForBusiness']['width'];
$height=Yii::app()->params['dialog']['findCustomerForBusiness']['height'];
$cs=Yii::app()->clientScript;
$cs->registerScriptFile('./js/modal.js');
$cs->registerScript('business_dialog',<<<END
function Block(){\$.modal('?r=dialog/findCustomerForBusiness&rt=create',{width:$width,height:$height,title:'请选择客户'});return false;}
$("#findCustomer").click(Block);
function calculate(){
	var vaild=true;
	var validator=$("form").validate();//alert(validator.element($('#Accident_record_plate_no')));
	var cost=0;
	validator.resetForm();
	vaild=validator.element($('#Business_detail_receivable_amount'))?vaild:false;
	vaild=validator.element($('#Business_detail_payable_amount'))?vaild:false;
	if(!vaild) {alert('请将信息填写完整信息!');return;}
	disparity=$('#Business_detail_receivable_amount').val()-$('#Business_detail_payable_amount').val();
	$("#Business_detail_disparity").val(Math.round(disparity*100)/100);
	if($('#Business_detail_receivable_amount').val()!=0){
		disparity_ratio=disparity/$('#Business_detail_receivable_amount').val();
		$("#Business_detail_disparity_ratio").val(Math.round(disparity_ratio*10000)/100);
	}
};
$("#calculate").click(calculate);
$("form").submit(calculate);
END
);
?>
<div class="yiiForm" style="width:753px;">
<?php
	echo EHtml::form();	
	EHtml::setOptions(array('errorElement'=> 'span'));
	EHtml::setScenario($update ? 'update' : 'create');				  		
?>
<div>注：<span class="required">*</span>为必填项</div>
<div id="leftaa" style="width:400px;">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'customer_name'); ?>
<?php echo EHtml::activeTextField($model,'customer_name',array('readOnly'=>'true','size'=>20,'class'=>'readonly')); ?>&nbsp;&nbsp;<a id="findCustomer" href="#">查找客户</a>
<?php echo CHtml::activeHiddenField($model,'fk_customer_id'); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'business_type',array('class'=>'label_left100',)); ?>
<?php echo EHtml::activeDropDownList($model,'business_type',$model->getBusinessTypeNames()); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'carrier_type',array('class'=>'label_left100',)); ?>
<?php echo EHtml::activeDropDownList($model,'carrier_type',$model->getCarrierTypeNames()); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'truck_times'); ?>
<?php echo EHtml::activeTextField($model,'truck_times',array('size'=>10)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'tonnage'); ?>
<?php echo EHtml::activeTextField($model,'tonnage',array('size'=>10)); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'occur_time'); ?>
<?php echo EHtml::activeTextField($model,'occur_time',array('size'=>10,'maxlength'=>10,'id'=>"occur_time",)); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'occur_time','ifFormat'=>'%Y-%m-%d',));?>
</div>
</div>
<div id="rightaa" style="width:350px;">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'receivable_amount'); ?>
<?php echo EHtml::activeTextField($model,'receivable_amount',array('size'=>10)); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'payable_amount'); ?>
<?php echo EHtml::activeTextField($model,'payable_amount',array('size'=>10)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'disparity'); ?>
<?php echo EHtml::activeTextField($model,'disparity',array('size'=>10,'readOnly'=>'true','class'=>'readonly')); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'disparity_ratio'); ?>
<?php echo EHtml::activeTextField($model,'disparity_ratio',array('size'=>10,'value'=>$model->disparity_ratio*100,'readOnly'=>'true','class'=>'readonly')); ?>
&nbsp;&nbsp;<input type="button" id="calculate" value="计算"/>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'loss_amount'); ?>
<?php echo EHtml::activeTextField($model,'loss_amount',array('size'=>10)); ?>
</div>
<div class="simple1">
</div>
</div>
<div class="simple4" style="border-top:0px;width:731px;">
<?php echo CHtml::activeLabelEx($model,'remark1'); ?>
<?php echo EHtml::activeTextArea($model,'remark1',array('rows'=>6, 'cols'=>65)); ?>
</div>
<div class="simple4" style="border-top:0px;width:731px;">
<?php echo CHtml::activeLabelEx($model,'remark2'); ?>
<?php echo EHtml::activeTextArea($model,'remark2',array('rows'=>6, 'cols'=>65)); ?>
</div>
<div class="action">
<?php echo EHtml::submitButton($update ? '更新信息' : '确认信息'); ?>
</div>

<?php echo EHtml::endForm(); ?>

</div><!-- yiiForm -->